import React from 'react'
import './autherAccount.scss'
import AreaData from "../../../component/areaData/areaData"
import utils from '../../../utils/utils'
import cookie from 'react-cookies'
import moment from 'moment'
import { List, Tabs, Row, Col,Select,DatePicker,Table,Radio,Button,Input,Card,Image,Descriptions,Switch } from 'antd';
import BreadcrumbNav from '../../../component/breadcrumb/breadcrumb'
import { EditOutlined, DeleteOutlined ,SettingOutlined,LoadingOutlined, PlusOutlined ,UploadOutlined} from '@ant-design/icons';
import {getUserPositionInfo,addUserAndAuthority,updUserAndAuthority,getAllAccounnt} from '../../../api/accountManage'
const { Option } = Select;
const { Column } = Table;
class autherAccount extends React.Component{
    constructor(props){
        super(props)
        this.state = {
            dataSource : [
               
              ],
              witchPro:1,
              department:''
        }
    }
    
    componentDidMount(){

        this.getAllAccounnt()
    }

    //获取账户信息
    getAllAccounnt = () => {
        let post_data = {
            auth_token:cookie.load('station_console_setting_web_login').auth_token
        }
        getAllAccounnt(post_data).then( res => {
            console.log(res)
            if(res.code == 0){
                this.setState({
                    dataSource:res.data
                })
            }
        })
    }


    // 查看详情
    toDetail = (record) => {
        window.location.href =`/index/auther/autherAccount/accDetail?uid=${record.id}&position_id=${record.position_id}`
    }

    // 新建账户
    toAdd = () => {
        window.location.href ='/index/auther/autherAccount/addNewAcc'
        
    }

    // 编辑
    toEdit = (record) => {
        window.location.href=`/index/auther/autherAccount/editAcc?uid=${record.id}&position_id=${record.position_id}`
        
    }

    // 点击单选按钮
    onChange = e => {
        console.log('radio checked', e.target.value);
        this.setState({
            witchPro: e.target.value,
        });
      };

    render(){
        const {dataSource,department} = this.state
        return (
            <div id="ContentMainList" className="autherAccount-con">
                <Row>
                    <Col span={24}>
                        <BreadcrumbNav />
                    </Col>
                    <Col span={24}>
                        <div className="tipss">
                            <span className="blue"></span>
                            <span>账号管理</span>
                            <Button onClick={this.toAdd.bind(this)} type='primary' style={{color:'#fff',float:'right',marginRight:'100px',borderRadius:'10px',padding:'10px',lineHeight:'3px'}}>
                                + 新建账户
                            </Button>
                        </div>
                       
                        <Table dataSource={dataSource} rowKey={record => record.key} scroll={{ x: '100%' }} pagination={false} locale={{ emptyText: '暂无数据' }}>
                            <Column title="账号姓名" dataIndex="user_name" width='110px' key='1' />
                            <Column title="手机号码" dataIndex="user_phone" width='200px' key='2' />
                            <Column title="岗位/职位" dataIndex="position_name" width='150px' key='3' />
                            <Column title="帐号状态" dataIndex="state_name" width='200px' key='4' />
                            <Column title="开户时间" dataIndex="add_time" width='100px' key='5' />
                            
                             <Column title="操作" width='200px' key='12' fixed='right'
                                render={record => {
                                    return <span>
                                        <Button type="text" style={{ display: 'inline-block', width: '40px' ,marginRight:'6px', color:'#2F3CF2'}} className="link" onClick={this.toDetail.bind(this, record)}>查看</Button>
                                        <Button type="text" style={{ display: 'inline-block', width: '40px' ,marginRight:'6px', color:'#2F3CF2'}} className="link" onClick={this.toEdit.bind(this, record)}><EditOutlined /></Button>
                                        
                                    </span>
                                    // return  record.deliver_state_name === '待付款' ? <span className="link" onClick={this.toDeliverPay.bind(this, record.deliver_id)}>立即付款</span> : <span className="link" onClick={this.toDetail.bind(this, record.deliver_id)}>查看详情</span>
                                }}
                            />
                        
                        </Table>
                    </Col>
                    

                </Row>
            </div>
        )
    }
}

export default autherAccount